package com.zq.danli;

/**
 * 测试单例类
 */
public class SingletonTest {
    public static void main(String[] args) {
//        饿汉单例
        SingletonEHan singletonEHan1 = SingletonEHan.getInstance();
        SingletonEHan singletonEHan2 = SingletonEHan.getInstance();
        System.out.println(singletonEHan1+"\n"+singletonEHan2);

        System.out.println();
        System.out.println();

//        懒汉单例
        SingletonLanHan singletonLanHan1 = SingletonLanHan.getInstance();
        SingletonLanHan singletonLanHan2 = SingletonLanHan.getInstance();
        System.out.println(singletonLanHan1+"\n"+singletonLanHan2);
    }
}
